<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
		<link rel="stylesheet" href="../../../bootstrap/bootstrap.css">
		<link rel="stylesheet" href="../../../bootstrap/bootstrap-responsive.css">
		<link rel="stylesheet" href="../../third-party/codemirror2.15/codemirror.css">
		<script type="text/javascript" src="../internal.js"></script>
		<script type="text/javascript" src="../../third-party/codemirror2.15/codemirror.js"></script>
		<script type="text/javascript" src="../../../jquery.js"></script>
        <style type="text/css">
            *{color: #838383;margin: 0;padding: 0}
            html,body {font-size: 12px;}
			body { padding-left: 20px;padding-right: 20px; }
        </style>
    </head>
    <body>
		<table class="table table-striped table-bordered" style="margin-top:18px;margin-bottom: 0;">
			<tr>
				<th><span>编辑层叠样式表</span> &nbsp; <span class="label label-important">不需要填写&lt;style&gt;标签</span></th>
			</tr>
			<tr>
				<td> <textarea id="cssext"></textarea> </td>
			</tr>
		</table> 
		<script type="text/javascript">
			var myCodeMirror;
			window.onload = function() {
				myCodeMirror = CodeMirror( function( elt ) {
					$G('cssext').parentNode.replaceChild(elt, $G('cssext'));
				}, 
				{value: $G('cssext').value,mode: "css",lineNumbers:true}	
			);
				InitCss();
			}
			function InitCss(){
				var sUrl =  parent.getItemUrl;
				ajax.request(sUrl, {timeout:60000,onsuccess:function (xhr) {
						try {
							if( xhr.responseText!='' ){
								myCodeMirror.setValue(xhr.responseText);
								myCodeMirror.focus();
							}
						} catch (e) {
							alert('Init error,please contact OA administrator');
							return false;
						}
					},
					error:function () {
						alert('Request TimeOut');
					}
				})
			}
			dialog.onok = function (){
				var sVal = myCodeMirror.getValue();
				var sUrl = 'wf.php?mod=workflowsetup&do=formdesignaction&act=extsubmit&op=css&formid=' + parent.formid + '&content=' + escape(sVal);
				ajax.request(sUrl, {timeout:60000,onsuccess:function (xhr) {
						try {
							if( xhr.responseText > 0 ){
								alert('保存成功');
								return true;
							}
						} catch (e) {
							alert('save error,please contact OA administrator');
							return false;
						}
					},
					error:function () {
						alert('Request TimeOut');
					}
				})
			}
		</script>
	</body>
</html>
